package com.maker.ai.tool;

import com.maker.ai.entity.Reservation;
import com.maker.ai.service.ReservationService;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

@Component
public class ReservationTool {

    @Autowired
    private ReservationService reservationService;
    @Tool("预约志愿填报服务")
    public String  addReservation(
            @P("考生姓名") String name,
            @P("考生性别") String gender,
            @P("考生手机号") String phone,
            @P("预约沟通时间,格式为：yyyy-MM-dd'T'HH:mm") String communicationTime,
            @P("考生所在省份") String province,
            @P("考生预估分数") Integer estimatedScore
    ) {
      return  reservationService.insert(new Reservation(null,name, gender, phone, LocalDateTime.parse(communicationTime), province, estimatedScore));
    }
    @Tool("根据用户手机号查询预约信息服务")
    public Reservation findReservationByPhone(
            @P("手机号") String phone
    ) {
        return reservationService.findByPhone(phone);
    }
    @Tool("查询所有预约信息服务")
    public List<Reservation> getAllReservations() {
        return reservationService.getAllReservations();
    }
    @Tool("根据用户姓名查询预约信息服务")
    public List<Reservation> findReservationByName(
            @P("姓名") String name
    ) {
        return reservationService.findByName(name);
    }
}
